home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Sprite 1984 - 1993
/
Sprite 1984 - 1993.iso
/
src
/
machserver
/
tests
/
setjmp
/
test.c
< prev
Wrap
C/C++ Source or Header
|
1992-03-12
|
471b
|
44 lines
/*
* Test program to verify that setjmp and longjmp work.
*/
#include <stdio.h>
#include <setjmp.h>
jmp_buf env;
main()
{
int ch;
for (;;) {
if (setjmp(env)) {
printf("longjmp.\n");
}
printf("? ");
ch = getone();
if (ch == EOF) {
exit(0);
} else {
printf("%c\n", ch);
}
}
}
getone()
{
return getone_b();
}
getone_b()
{
int ch;
ch = getchar();
if (ch == 'l') {
longjmp(env, 1);
} else {
return ch;
}
}